--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit be21d7830fc5d8adb4362db8ebbfa4c0d2dde0ae
Parents : 4299522
Author : Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-05-02T05:59:00-05:00
fix: update filename sanitization to allow hyphens as literal characters
Changes
2 files changed, 3 insertions(+), 2 deletions(-)
Diff
diff --git a/android/app/src/main/java/com/meshchatx/MeshchatDownloadUtils.java b/android/app/src/main/java/com/meshchatx/MeshchatDownloadUtils.java
index 8ad709db..a19da78f 100644
--- a/android/app/src/main/java/com/meshchatx/MeshchatDownloadUtils.java
+++ b/android/app/src/main/java/com/meshchatx/MeshchatDownloadUtils.java
@@ -16,7 +16,8 @@ final class MeshchatDownloadUtils {
if (base.isEmpty()) {
return "download.bin";
}
- base = base.replaceAll("[^A-Za-z0-9._ -]+", "_").trim();
+ // Hyphen must be first or last in the class so it is literal, not a range (space..hyphen would include '*').
+ base = base.replaceAll("[^A-Za-z0-9._ \\-]+", "_").trim();
if (base.isEmpty()) {
return "download.bin";
}
diff --git a/android/app/src/test/java/com/meshchatx/MeshchatDownloadUtilsTest.java b/android/app/src/test/java/com/meshchatx/MeshchatDownloadUtilsTest.java
index 1761ea8b..73cf40a0 100644
--- a/android/app/src/test/java/com/meshchatx/MeshchatDownloadUtilsTest.java
+++ b/android/app/src/test/java/com/meshchatx/MeshchatDownloadUtilsTest.java
@@ -19,7 +19,7 @@ public class MeshchatDownloadUtilsTest {
@Test
public void sanitize_replacesUnsafeCharacters() {
- Assert.assertEquals("mesh_x_folders.json", MeshchatDownloadUtils.sanitizeFileName("mesh:x?folders*.json"));
+ Assert.assertEquals("mesh_x_folders_.json", MeshchatDownloadUtils.sanitizeFileName("mesh:x?folders*.json"));
}
@Test
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────